/**
 * 禁用
 * @param idList id列表
 * @param disableApi 禁用api
 * @param callback 回调
 */
export function useDisable(
  idList: Ref<string[]>,
  disableApi: (idList: string[]) => Promise<any>,
  callback?: () => void,
) {
  function disable() {
    if (idList.value.length === 0) {
      Message({
        type: 'warning',
        message: '请选择要禁用的数据',
      })
      return
    }
    ElMessageBox.confirm(
      `确定禁用已选择的 ${idList.value.length} 条数据?`,
      {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
      },
    )
      .then(async () => {
        await disableApi(idList.value)
        Message({
          type: 'success',
          message: '禁用成功',
        })
        callback && callback()
      })
  }
  return [disable] as const
}
